package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Hotes;
import com.ruoyi.system.service.IHotesService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 酒店模块Controller
 * 
 * @author lsj
 * @date 2024-12-21
 */
@RestController
@RequestMapping("/system/hotes")
public class HotesController extends BaseController
{
    @Autowired
    private IHotesService hotesService;

    /**
     * 查询酒店模块列表
     */
    @PreAuthorize("@ss.hasPermi('system:hotes:list')")
    @GetMapping("/list")
    public TableDataInfo list(Hotes hotes)
    {
        startPage();
        List<Hotes> list = hotesService.selectHotesList(hotes);
        return getDataTable(list);
    }

    /**
     * 导出酒店模块列表
     */
    @PreAuthorize("@ss.hasPermi('system:hotes:export')")
    @Log(title = "酒店模块", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Hotes hotes)
    {
        List<Hotes> list = hotesService.selectHotesList(hotes);
        ExcelUtil<Hotes> util = new ExcelUtil<Hotes>(Hotes.class);
        util.exportExcel(response, list, "酒店模块数据");
    }

    /**
     * 获取酒店模块详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:hotes:query')")
    @GetMapping(value = "/{hotelid}")
    public AjaxResult getInfo(@PathVariable("hotelid") Long hotelid)
    {
        return success(hotesService.selectHotesByHotelid(hotelid));
    }

    /**
     * 新增酒店模块
     */
    @PreAuthorize("@ss.hasPermi('system:hotes:add')")
    @Log(title = "酒店模块", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Hotes hotes)
    {
        return toAjax(hotesService.insertHotes(hotes));
    }

    /**
     * 修改酒店模块
     */
    @PreAuthorize("@ss.hasPermi('system:hotes:edit')")
    @Log(title = "酒店模块", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Hotes hotes)
    {
        return toAjax(hotesService.updateHotes(hotes));
    }

    /**
     * 删除酒店模块
     */
    @PreAuthorize("@ss.hasPermi('system:hotes:remove')")
    @Log(title = "酒店模块", businessType = BusinessType.DELETE)
	@DeleteMapping("/{hotelids}")
    public AjaxResult remove(@PathVariable Long[] hotelids)
    {
        return toAjax(hotesService.deleteHotesByHotelids(hotelids));
    }
}
